import { InputNumber, Tooltip } from 'antd';
import pageStyles from '@/common/pageLayout.less';
import { DictionaryRenderFun, formatDecimal } from '../../Acommon';
import { removeDateHmsStr } from '@/utils';

/** 表格配置 */
const assetTableConfig = () => {
  let tableConfig: Record<string, any>[] = [
    {
      title: '资产编号',
      dataIndex: 'assetCode',
      key: 'assetCode',
      width: 160,
      fixed: 'left',
      visible: true,
      sorter: (a: any, b: any) => (a.assetCode > b.assetCode ? 1 : -1),
      render: (text: string) => {
        return (
          <Tooltip title={text}>
            <div className={pageStyles['over-flow-hidden']}>{text || '--'}</div>
          </Tooltip>
        );
      },
    },
    {
      title: '资产名称',
      dataIndex: 'assetName',
      key: 'assetName',
      width: 120,
      fixed: 'left',
      ellipsis: {
        showTitle: true,
      },
      visible: true,
      unDrag: true,
      sorter: (a: any, b: any) => (a.assetName > b.assetName ? 1 : -1),
      render: (text: string) => {
        return (
          <Tooltip title={text}>
            <div className={pageStyles['over-flow-hidden']}>{text || '--'}</div>
          </Tooltip>
        );
      },
    },
    {
      title: '资产分类',
      dataIndex: 'assetClassName',
      key: 'assetClassName',
      width: 120,
      ellipsis: {
        showTitle: true,
      },
      visible: true,
      unDrag: true,
      sorter: (a: any, b: any) => (a.assetClassName > b.assetClassName ? 1 : -1),
      render: (text: number | null) => DictionaryRenderFun({ text, isState: false }),
    },
    {
      title: '品牌',
      dataIndex: 'brandType',
      key: 'brandType',
      width: 120,
      visible: true,
      sorter: (a: any, b: any) => (a.brandType > b.brandType ? 1 : -1),
      render: (text: number | null) => DictionaryRenderFun({ text, isState: false }),
    },
    {
      title: '规格型号',
      dataIndex: 'paramsInfo',
      key: 'paramsInfo',
      width: 170,
      visible: true,
      sorter: (a: any, b: any) => (a.paramsInfo > b.paramsInfo ? 1 : -1),
      render: (text: string) => {
        return (
          <Tooltip title={text}>
            <div className={pageStyles['over-flow-hidden']}>{text || '--'}</div>
          </Tooltip>
        );
      },
    },
    {
      title: '数量',
      dataIndex: 'quantityOrArea',
      key: 'quantityOrArea',
      width: 100,
      visible: true,
      sorter: (a: any, b: any) => (a.quantityOrArea > b.quantityOrArea ? 1 : -1),
      render: (text: number | null) => formatDecimal(text),
    },
    {
      title: '计量单位',
      dataIndex: 'unitOfMeasurementName',
      key: 'unitOfMeasurementName',
      width: 150,
      visible: true,
      sorter: (a: any, b: any) => (a.unitOfMeasurementName > b.unitOfMeasurementName ? 1 : -1),
      render: (text: number | null) => DictionaryRenderFun({ text, isState: false }),
    },
    {
      title: '资产原值（元）',
      dataIndex: 'totalValue',
      key: 'totalValue',
      width: 170,
      visible: true,
      sorter: (a: any, b: any) => (a.totalValue > b.totalValue ? 1 : -1),
      render: (text: number | null) => formatDecimal(text),
    },
    {
      title: '管理部门',
      dataIndex: 'assetDepartmentName',
      key: 'assetDepartmentName',
      width: 150,
      visible: true,
      sorter: (a: any, b: any) => (a.useDepartmentName > b.useDepartmentName ? 1 : -1),
      render: (text: string) => {
        return (
          <Tooltip title={text}>
            <div className={pageStyles['over-flow-hidden']}>{text || '--'}</div>
          </Tooltip>
        );
      },
    },
    {
      title: '管理人',
      dataIndex: 'asseterName',
      key: 'asseterName',
      width: 150,
      visible: true,
      sorter: (a: any, b: any) => (a.userName > b.userName ? 1 : -1),
      render: (text: string) => {
        return (
          <Tooltip title={text}>
            <div className={pageStyles['over-flow-hidden']}>{text || '--'}</div>
          </Tooltip>
        );
      },
    },
    {
      title: '使用部门',
      dataIndex: 'useDepartmentName',
      key: 'useDepartmentName',
      width: 150,
      visible: true,
      sorter: (a: any, b: any) => (a.useDepartmentName > b.useDepartmentName ? 1 : -1),
      render: (text: string) => {
        return (
          <Tooltip title={text}>
            <div className={pageStyles['over-flow-hidden']}>{text || '--'}</div>
          </Tooltip>
        );
      },
    },
    {
      title: '使用人',
      dataIndex: 'userName',
      key: 'userName',
      width: 150,
      visible: true,
      sorter: (a: any, b: any) => (a.userName > b.userName ? 1 : -1),
      render: (text: string) => {
        return (
          <Tooltip title={text}>
            <div className={pageStyles['over-flow-hidden']}>{text || '--'}</div>
          </Tooltip>
        );
      },
    },
    {
      title: '存放区域',
      dataIndex: 'locationName',
      key: 'locationName',
      width: 150,
      visible: true,
      sorter: (a: any, b: any) => (a.locationName > b.locationName ? 1 : -1),
      render: (text: number | null) => DictionaryRenderFun({ text, isState: false }),
    },
    {
      title: '详细地点',
      dataIndex: 'locationInfo',
      key: 'locationInfo',
      width: 180,
      visible: true,
      sorter: (a: any, b: any) => (a.locationInfo > b.locationInfo ? 1 : -1),
      render: (text: string) => {
        return (
          <Tooltip title={text}>
            <div className={pageStyles['over-flow-hidden']}>{text || '--'}</div>
          </Tooltip>
        );
      },
    },
    {
      title: '取得方式',
      dataIndex: 'obtainTypeName',
      key: 'obtainTypeName',
      width: 150,
      visible: true,
      sorter: (a: any, b: any) => (a.obtainTypeName > b.obtainTypeName ? 1 : -1),
      render: (text: number | null) => DictionaryRenderFun({ text, isState: false }),
    },
    {
      title: '取得日期',
      dataIndex: 'obtainDate',
      key: 'obtainDate',
      width: 150,
      visible: true,
      sorter: (a: any, b: any) => (a.obtainDate > b.obtainDate ? 1 : -1),
      render: (text: string) => removeDateHmsStr(text) || '--',
    },
    {
      title: '合同编号',
      dataIndex: 'contractCode',
      key: 'contractCode',
      width: 150,
      visible: true,
      sorter: (a: any, b: any) => (a.contractCode > b.contractCode ? 1 : -1),
      render: (text: string) => {
        return (
          <Tooltip title={text}>
            <div className={pageStyles['over-flow-hidden']}>{text || '--'}</div>
          </Tooltip>
        );
      },
    },
    {
      title: '财务入账状态',
      dataIndex: 'entryStateName',
      key: 'entryStateName',
      width: 150,
      visible: true,
      sorter: (a: any, b: any) => (a.entryStateName > b.entryStateName ? 1 : -1),
      render: (text: number | null) => DictionaryRenderFun({ text, isState: false }),
    },
  ];
  return tableConfig;
};

export { assetTableConfig };
